Eclipse Platform
Pre-release 3.0

org.eclipse.jface.resource
Class ColorRegistry

java.lang.Object
  extended byorg.eclipse.jface.resource.ColorRegistry

public class ColorRegistry
extends Object

A color registry maintains a mapping between symbolic color names and SWT Colors.

A color registry owns all of the Color objects registered with it, and automatically disposes of them when the SWT Display that creates the Colors is disposed. Because of this, clients do not need to (indeed, must not attempt to) dispose of Color objects themselves.

Methods are provided for registering listeners that will be kept apprised of changes to list of registed colors.

Clients may instantiate this class (it was not designed to be subclassed).

Since:
3.0

Constructor Summary
ColorRegistry()
          Create a new instance of the receiver that is hooked to the current display.
ColorRegistry(Display display)
          Create a new instance of the receiver.
 
Method Summary
 void addListener(IPropertyChangeListener listener)
          Adds a property change listener to this registry.
 Color get(String symbolicName)
          Returns the color associated with the given symbolic color name, or null if no such definition exists.
 RGB getRGB(String symbolicName)
          Returns the color data associated with the given symbolic color name.
 boolean hasValueFor(String colorKey)
          Return whether or not the receiver has a value for the supplied color key.
 void put(String symbolicName, RGB colorData)
          Adds (or replaces) a color to this color registry under the given symbolic name.
 void removeListener(IPropertyChangeListener listener)
          Removes the given listener from this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorRegistry

public ColorRegistry()
Create a new instance of the receiver that is hooked to the current display.

See Also:
Display.getCurrent()

ColorRegistry

public ColorRegistry(Display display)
Create a new instance of the receiver.

Parameters:
display - the Display to hook into.
Method Detail

addListener

public void addListener(IPropertyChangeListener listener)
Adds a property change listener to this registry.

Parameters:
listener - a property change listener

get

public Color get(String symbolicName)
Returns the color associated with the given symbolic color name, or null if no such definition exists.

Parameters:
symbolicName - symbolic color name.
Returns:
the Color.

getRGB

public RGB getRGB(String symbolicName)
Returns the color data associated with the given symbolic color name.

Parameters:
symbolicName - symbolic color name.
Returns:
the RGB data.

hasValueFor

public boolean hasValueFor(String colorKey)
Return whether or not the receiver has a value for the supplied color key.

Parameters:
colorKey - the key for the color.
Returns:
true if there is a key for the color.

put

public void put(String symbolicName,
                RGB colorData)
Adds (or replaces) a color to this color registry under the given symbolic name.

A property change event is reported whenever the mapping from a symbolic name to a color changes. The source of the event is this registry; the property name is the symbolic color name.

Parameters:
symbolicName - the symbolic color name
colorData - an RGB object

removeListener

public void removeListener(IPropertyChangeListener listener)
Removes the given listener from this registry. Has no affect if the listener is not registered.

Parameters:
listener - a property change listener

Eclipse Platform
Pre-release 3.0

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.